package com.ktjy.mapper.user;

import java.lang.reflect.Field;

public class AccessPersonFields {
    public static void main(String[] args) {
        try {
            Class clz=Class.forName("com.ktjy.mapper.user.Person");
            Object person=clz.newInstance();
            Field name=clz.getDeclaredField("name");
            name.setAccessible(true);//暴力破解
            System.out.println("赋值前的name:"+name.get(person));
            name.set(person,"New Person");
            System.out.println("赋值后的name:"+name.get(person));
        }catch (Exception e) {
            e.printStackTrace();
        }
    }
}
